let queue=[]
let state={count:0}
function setState(newState){
    queue.push(newState)
}
function handleClick(){
    setState({count:1})
    console.log(state.count);
    setState({count:2})
    console.log(state.count);
    setState({count:3})
    console.log(state.count);
    setState({count:4})
    console.log(state.count);
}
handleClick();
queue.forEach((newState)=>{
    state=newState
})
console.log(state.count);